#!/bin/bash
#
# Script to install the dependencies necessary to make ZenMP3 work in a Mac.
# We assume that the environment already has Python 2.7 installed.
#
# Copyright Vitor Sonoki 2012 - 2015 all rights reserved.
#
#    This file is part of ZenMP3 
# 
#    ZenMP3 is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
# 
#    ZenMP3 is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
# 
#    You should have received a copy of the GNU General Public License
#    along with ZenMP3.  If not, see <http://www.gnu.org/licenses/>.
#

echo "====================="
echo "Downloading ffmpeg... (~22MB)"
curl https:/http://ffmpegmac.net/resources/SnowLeopard_Lion_Mountain_Lion_Mavericks_19.01.2015.zip/ -o SnowLeopard_Lion_Mountain_Lion_Mavericks_19.01.2015.zip && \
    echo "Downloaded."

echo "====================="
echo "Unpacking ffmpeg..."
unzip SnowLeopard_Lion_Mountain_Lion_Mavericks_19.01.2015.zip && \
    echo "Done."

echo "====================="
echo "Downloading youtube-dl..."
curl https://yt-dl.org/downloads/2015.01.16/youtube-dl -o youtube-dl && \
    echo "Downloaded."

echo "====================="
echo "Preparing all binaries and executables..."
chmod a+x ffmpeg youtube-dl zenmp3 && echo "All binaries ready!"

echo "The dependencies will be installed in the system." 
echo "For that, you need to enter your password:"

sudo mv youtube-dl /usr/local/bin && \
    sudo mv ffmpeg /usr/local/bin && \
    sudo cp zenmp3 /usr/local/bin \
    echo "Dependencies installed!"

echo "You can now run ZenMP3 by typing zenmp3 into the terminal,"
echo "Just make sure that you run 'sudo youtube-dl -U' frequently!"
echo "*** END OF INSTALLER ***"
